package com.qf.Service.Impl;/*
 *
 */

import com.qf.Dao.GoodsDao;
import com.qf.Dao.GoodsTypeDao;
import com.qf.Dao.Impl.GoodsDaoImpl;
import com.qf.Dao.Impl.GoodsTypeDaoImpl;
import com.qf.Domain.Goods;
import com.qf.Domain.GoodsType;
import com.qf.Domain.PageBean;
import com.qf.Service.GoodService;

import java.util.ArrayList;
import java.util.List;

public class GoodsServiceImpl implements GoodService {
    GoodsDao goodsDao=new GoodsDaoImpl();
    @Override
    public PageBean<Goods> select(int pageNum, int pageSize, String where,  ArrayList<Object> list) {
        long totalSize=goodsDao.selectCount(where,list);
        //System.out.println(totalSize);
        List<Goods> data=goodsDao.selectData(pageNum,pageSize,where,list);
        //System.out.println(data.toString());
        PageBean<Goods> pageBean=new PageBean<>(pageNum, pageSize,totalSize,data );
        //System.out.println(pageBean.toString());
        return pageBean;
    }

    @Override
    public Goods fingById(int i) {
        Goods goods = goodsDao.selectById(i);
        GoodsTypeDao goodsTypeDao=new GoodsTypeDaoImpl();
        GoodsType goodsType=goodsTypeDao.selectById(goods.getTypeid());
        goods.setGoodsType(goodsType);
        return goods;
    }
}
